import { ipcRenderer } from 'electron'
import { domReady } from './utils'
import { useLoading } from './loading'


// -------------------------------------------------
// 挂在 ipcRenderer 到渲染进程使用，preload.ts 不再做任何事情

window.ipcRenderer = ipcRenderer

// -------------------------------------------------
// 加载动画

const { appendLoading, removeLoading } = useLoading()
domReady().then(appendLoading)
window.onmessage = ev => {
  ev.data.payload === 'removeLoading' && removeLoading()
}
setTimeout(removeLoading, 4999)
